package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {

    @RequestMapping("test")
//    绑定共享数据
    public String test(HttpServletRequest req) {
        req.setAttribute("name", "刘勇");
        req.setAttribute("age", 10);

        List<UserBean> userList = new ArrayList<>();
        userList.add(new UserBean(1, "昭君", "2132142132151"));
        userList.add(new UserBean(2, "收到", "1341232443"));
        userList.add(new UserBean(3, "色完全", "21314512"));
        userList.add(new UserBean(4, "的撒的", "09874564"));
        userList.add(new UserBean(5, "企鹅", "45686836"));
        req.setAttribute("list", userList);

//        请求转发到指定页面
        return "/showInfo.html";
    }
}
